<%@page pageEncoding="UTF-8" %>
<!doctype html>
<html lang="zh-cmn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@include file="/WEB-INF/pages/comm/YueHead.jsp"%>
<title></title>
</head>
<body>
	<div>
		<div id="toolbar">
	    	<h3>管理员列表</h3>
	    </div>
		<table 
			id="mtable"
			data-url="${ctx }/manager/list"
			data-toggle="table"
			data-toolbar="#toolbar"
			data-toolbar-align="left"
			data-striped="true"
			data-pagination="true"
			data-side-pagination="server"
			data-search="true"
			data-page-size="3"
		>
			<!-- data-detail-view="true" -->
			<!-- data-detail-formatter="detail" -->
		
		<thead>
			<tr>
				<!-- <th data-radio="true"></th> -->
				<th data-field="mgId">编号</th>
	            <th data-field="mgName">名称</th>
	            <th data-field="mgPWD">密码</th>
	            <th data-field="mgRemark">备注</th>
				<!-- <th data->操作</th> -->
				<th data-formatter="mgoperation" data-events="optEvents">操作</th>
			
			</tr>
		
		</thead>
		
		
		
		
		
		</table>
	
		<div id="modalEditMG">	
			<form id="formEditMG" class="form-horizontal dis" style="margin-top: 20px;">
				<div class="form-group">
					<label for="mgId" class="control-label col-md-3 text-right">用户编号:</label>
					<div class="col-md-8">
						<input type="text" class="form-control" name="mgId"  readonly="readonly"/>
					</div>
				</div>
				<div class="form-group">
					<label for="mgName" class="control-label col-md-3 text-right">名称:</label>
					<div class="col-md-8">
						<input type="text" class="form-control" name="mgName" />
					</div>
				</div>
				<div class="form-group">
					<label for="mgPWD" class="control-label col-md-3 text-right">密码:</label>
					<div class="col-md-8">
						<input type="text" class="form-control" name="mgPWD" />
					</div>
				</div>
				<div class="form-group">
					<label for="mgRemark" class="control-label col-md-3 text-right">备注:</label>
					<div class="col-md-8">
						<input type="text" class="form-control" name="mgRemark" value="${row.mgRemark }"/>
						<!-- <span style="font-size: 14px;color: red">注:最低预存500￥</span> -->
					</div>
				</div>
			</form>
		</div>
	
	</div>
</body>
<%@include file="/WEB-INF/pages/comm/YueFoot.jsp"%>
<script type="text/javascript">


	$(function(){
		$("#modalEditMG").dialog({
			title:'编辑管理员信息',
			btnBind:function(){
				var params=$("#formEditMG").serialize();
				
				$.post("manager/edit",params,function(msg){
/* 					if(msg=="success"){
						$("#grant1").dialog("close")
						swal({  
					           text: "新办一卡通成功",  
					           type: "success",  
					           confirmButtonText: '确认', 
					           confirmButtonColor: '#f8bb86',  
					      }).then(function(isConfirm){
					    	  if (isConfirm == true) {
					    		  location="yiCardJsp";
					    	  }
					      });
					} */
					$("#modalEditMG").dialog("close");
		    		toastr.success("修改成功！"); 
		    		window.setTimeout("window.location='system/manager'",1500);
				});
				
				
			}
		});
	});



	function mgoperation(value,row,index){
		var shouquan='<a  class="glyphicon glyphicon-th shouquan" href="javascript:void(0)">权限管理</a>' ;
		var edit='<a  class="glyphicon glyphicon-pencil col-lg-offset-1 col-md-offset-1 edit" href="javascript:void(0)">编辑信息</a>';
		var del = '<a  class="glyphicon glyphicon-trash col-lg-offset-1 col-md-offset-1 del" href="javascript:void(0)" >删除</a>';

		return shouquan+edit+del; 
	};


	
	window.optEvents={
		"click .del":function(e,value,row,index){
			mgdel(row);
		},
		"click .edit":function(e,value,row,index){
			mgedit(row);
		},		
		"click .shouquan":function(e,value,row,index){
			mgshouquan(row);
		}
	};
	
	
	
	
	
	function mgdel(row){
		/* alert(row1);
		row1 = JSON.parse(row1);
		alert(row1); */
		
		swal({  
			   title:"删除操作",
	           text: "确定删除该用户"+row.mgName+"?", 
	           type: "warning",
	           confirmButtonText: '确认',
	           showCancelButton:true,
	           cancelButtonText:'取消',
	           confirmButtonColor: '#32CD32',
	           background:'#ADD8E6',
	      }).then(function(isConfirm){
	    	  if (isConfirm === true) {  
	    		  
	    		  $.post("manager/delOne",{mgId:row.mgId},function(res){
	    			  
	    		  });
	    		  
	    		  //location="system/manager";
	    		  toastr.success("删除成功！"); 
	    		  window.setTimeout("window.location='system/manager'",1500);

	    	  }
	      }); 

	};
	
	function mgedit(row){
		
/* 		$("#yId2").val(rows[0].yId);
		$("#uName2").val(rows[0].yiCardUser.uName);
		$("#yMoney2").val(rows[0].yMoney);
		$("#uCard2").val(rows[0].yiCardUser.uCard);
		$("#state2").val('0'); */
		
		$("#modalEditMG input[name='mgId']").val(row.mgId);
		$("#modalEditMG input[name='mgName']").val(row.mgName);		
		$("#modalEditMG input[name='mgPWD']").val(row.mgPWD);		
		$("#modalEditMG input[name='mgRemark']").val(row.mgRemark);		
		
		
		
		$('#modalEditMG').dialog("open");
/* 		$("#modalEditMG").dialog({
			title:'编辑管理员信息',
			btnBind:function(){
				alert('ok');
			}
			这段代码放在ready里
		}); */
	};

	function mgshouquan(row){
		
	};
</script>
</html>